<%inherit file="base.html"/>

<%def name="head()">
<script>
    function deleteDomain(domain_id) {
        if (confirm("确认删除吗？")) {
            var params = {domain_id: domain_id, _xsrf: '${handler.xsrf_token}'};
            $.post("/domain/delete", params, function (data) {
                if (data.code > 0) {
                    alert(data.msg)
                    return false;
                }
                else {
                    window.location.href = "/domain";
                }
            }, "json");
        }
    }

</script>
</%def>

<%def name="body()">
<section class="content">
    <div class="box box-primary">
        <div class="box-header">
            <i class="fa fa-sitemap"></i>
            <h3 class="box-title">域信息列表</h3>
        </div>
        <div class="box-body">
            <div class="container">
                % if permit.match(current_user.username,'/domain/add'):
                <div class="pull-right bottom10">
                     <a href="/domain/add" class="btn btn-sm btn-info">增加域信息</a>
                </div>
                % endif

                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>域编码</th>
                            <th>Portal模版</th>
                            <th>域描述</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        % for domain in page_data.result:
                            <tr>
                                <td><a href="/domain/detail?domain_id=${domain.id}">${domain.domain_code}</a></td>
                                <td>${domain.tpl_name}</td>
                                <td>${domain.domain_desc}</td>
                                <td>
                                    % if permit.match(current_user.username,'/domain/update'):
                                    <a class="opt-btn btn-default" href="/domain/update?domain_id=${domain.id}">修改</a>
                                    % endif
                                    % if permit.match(current_user.username,'/domain/delete'):
                                    <a class="opt-btn btn-default" href="javascript:deleteDomain('${domain.id}')">删除</a>
                                    % endif
                                </td>
                            </tr>
                        % endfor
                    </tbody>
                </table>
                ${page_data.render()}
            </div>
        </div>
    </div>
</section>
</%def>